<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 
<%@ include file="../common/tags.jsp"%>  
<%String path = request.getContextPath();%>
<form id="pagerForm" method="post" action="<%=path %>/msgTemplate/listMsgTemplate.action">
	<input type="hidden" name="pageRequest" value="1" />
	<input type="hidden" name="pageNum" value="${paginator.pageIndex}" />
	<input type="hidden" name="numPerPage" value="${paginator.pageSize}" />
</form>

<div class="pageHeader">
	<form onsubmit="return navTabSearch(this);" rel="pagerForm" action="<%=path %>/msgTemplate/listMsgTemplate.action" method="post">
	<div class="searchBar">
		<ul class="searchContent">
			<li>
				<label style="text-align: right;">模板类型：</label>
				<select name="msgTemplateVO.type" class="combox">
					<option value="">选择模板类型</option>
					<c:forEach var="item" items="${types}">
						<option value="${item.name}" ${msgTemplateVO.type eq item.name?"selected":"" }>${item.title}</option>
					</c:forEach>
				</select>
			</li>
			<li>
				<label style="text-align: right;">状态：</label>
				<select name="msgTemplateVO.status" class="combox">
					<option value="">选择状态</option>
					<c:forEach var="item" items="${statuses}">
						<option value="${item.name}" ${msgTemplateVO.status eq item.name?"selected":"" }>${item.title}</option>
					</c:forEach>
				</select>
			</li>
			<li>
				<label style="text-align: right;">适用范围：</label>
				<select name="msgTemplateVO.scope" class="combox">
					<option value="">选择适用范围</option>
					<c:forEach var="item" items="${scopes}">
						<option value="${item.name}" ${msgTemplateVO.scope eq item.name?"selected":"" }>${item.title}</option>
					</c:forEach>
				</select>
			</li>
			<li>
				<label style="text-align: right;">模板用途：</label>
				<select name="msgTemplateVO.targetType">
					<option value="">选择模板用途</option>
					<c:forEach var="item" items="${templateTargets}">
						<option value="${item.name}" ${msgTemplateVO.targetType eq item.name?"selected":"" }>${item.title}</option>
					</c:forEach>
				</select>
			</li>
		</ul>
		<ul class="searchContent">
			<li>
				<label style="text-align: right;">标题：</label>
				<input type="text" name="msgTemplateVO.name" value="<s:property value="msgTemplateVO.name" />" />
			</li>
			<li>
				<label style="text-align: right;">内容：</label>
				<input type="text" name="msgTemplateVO.content" value="<s:property value="msgTemplateVO.content" />" />
			</li>
			<c:if test="${SESSION_USER.customer != null}">
				<li>
					<input type="text" id="customerIds" name="msgTemplateVO.customerIds" value="${SESSION_USER.customer.id}" type="hidden">
				</li>
			</c:if>
			<c:if test="${SESSION_USER.customer == null}">
				<li>
					<label style="text-align: right;">商户：</label>
					<input id="customerIds" name="msgTemplateVO.customerIds" value="${msgTemplateVO.customerIds}" type="hidden">
					<input name="msgTemplateVO.customerNames" onclick="$('#msgTemplateList_a_btnLook').click();" type="text" style="cursor: pointer;float: left;" value="${msgTemplateVO.customerNames}" />
					<!-- <a class="btnLook" id="msgTemplateList_a_btnLook" href="<%=path%>/customer/listCustomer.action?searchType=msgTemplate" lookupGroup="msgTemplateVO">选择</a> -->
				</li>
			</c:if>
		</ul>
		<div class="subBar">
			<ul>
				<li><div class="buttonActive"><div class="buttonContent"><button type="submit">查询</button></div></div></li>
			</ul>
		</div>
	</div>
	</form>
</div>
<div class="pageContent">
	<div class="panelBar">
		<ul class="toolBar">
		<shiro:hasPermission name="addMsgTemplate">
			<li><a class="add" href="<%=path %>/msgTemplate/addMsgTemplate.action" target="navTab"><span>添加</span></a></li>
		</shiro:hasPermission>
		<shiro:hasPermission name="deleteMsgTemplate">
			<li><a title="确实要删除这些记录吗?" target="selectedTodo" rel="ids" postType="string" href="<%=path %>/msgTemplate/deleteMsgTemplate.action" class="delete"><span>删除</span></a></li>
		</shiro:hasPermission>
		<shiro:hasPermission name="editMsgTemplate">
			<li><a class="edit" href="<%=path %>/msgTemplate/editMsgTemplate.action?msgTemplateVO.id={sid_user}" target="navTab" warn="请选择一条记录"><span>修改</span></a></li>
		</shiro:hasPermission>
		<!--
		<shiro:hasPermission name="approveMsgTemplate">
			<li><a title="确实要审批这些记录吗?" target="selectedTodo" rel="ids" refreshNavTabId="msgtemplateList" postType="string" href="<%=path %>/msgTemplate/approveMsgTemplate.action" class="delete"><span>审批</span></a></li>
		</shiro:hasPermission>
		-->
		<shiro:hasPermission name="activeMsgTemplate">
			<li><a title="确实要启用这些模板吗?" target="selectedTodo" rel="ids" refreshNavTabId="msgtemplateList" postType="string" href="<%=path %>/msgTemplate/activeMsgTemplate.action" class="delete"><span>启用</span></a></li>
		</shiro:hasPermission>
		<shiro:hasPermission name="unactiveMsgTemplate">
			<li><a title="确实要禁用这些模板吗?" target="selectedTodo" rel="ids" refreshNavTabId="msgtemplateList" postType="string" href="<%=path %>/msgTemplate/unactiveMsgTemplate.action" class="delete"><span>禁用</span></a></li>
		</shiro:hasPermission>
		</ul>
	</div>
	<table class="table" width="100%" layoutH="164">
		<thead>
			<tr>
				<th width="30"><input type="checkbox" group="ids" class="checkboxCtrl"></th>
				<th width="80">模板标题</th>
				<th width="80">模板类型</th>
				<th width="300px">模板内容</th>
				<th width="50">状态</th>
				<th width="80">商户</th>
				<th width="80">适用范围</th>
				<th width="120">模板用途</th>
				<th width="100">操作</th>
			</tr>
		</thead>
		<tbody>
			<s:iterator value="msgTemplateList" id="msgTemplate" status="st">
			<tr target="sid_user" rel="<s:property value="id" />">
				<td><input name="ids" value="<s:property value="id" />" type="checkbox"></td>
				<td><s:property value="name" /></td>	
             	<td><s:property value="typeTitle" /></td>	
             	<td><s:property value="content" /></td>	
             	<td><s:property value="statusTitle" /></td>	
             	<td><s:property value="customerNames" /></td>	
             	<td><s:property value="scopeTitle" /></td>	
             	<td><s:property value="targetTypeTitle" /></td>	
				<td>
					<shiro:hasPermission name="deleteMsgTemplate">
						<a title="确实要删除这条记录吗?" target="ajaxTodo" href="<%=path %>/msgTemplate/deleteMsgTemplate.action?ids=<s:property value="id" />" class="btnDel">删除</a>
					</shiro:hasPermission>
					<shiro:hasPermission name="editMsgTemplate">
						<a title="编辑" target="navTab" href="<%=path %>/msgTemplate/editMsgTemplate.action?msgTemplateVO.id=<s:property value="id" />" class="btnEdit">编辑</a>
					</shiro:hasPermission>
					<shiro:hasPermission name="viewMsgTemplate">
						<a title="查看" target="navTab" href="<%=path %>/msgTemplate/viewMsgTemplate.action?msgTemplateVO.id=<s:property value="id" />" class="btnView">查看</a>
					</shiro:hasPermission>
				</td>
			</tr>
			</s:iterator>
		</tbody>
	</table>
	<div class="panelBar">
		<div class="pages">
				<span>显示</span>
				<select class="combox" name="numPerPage" onchange="navTabPageBreak({numPerPage:this.value})">
					<option value="15" <c:if test="${paginator.pageSize==15}">selected='selected'</c:if> >15</option>
					<option value="30" <c:if test="${paginator.pageSize==30}">selected='selected'</c:if> >30</option>
					<option value="50" <c:if test="${paginator.pageSize==50}">selected='selected'</c:if> >50</option>
					<option value="100" <c:if test="${paginator.pageSize==100}">selected='selected'</c:if> >100</option>
					<option value="200" <c:if test="${paginator.pageSize==200}">selected='selected'</c:if> >200</option>
				</select>
				<span>条，共${paginator.totalCount}条</span>
			</div>
			<div class="pagination" targetType="navTab" totalCount="${paginator.totalCount}" 
				numPerPage="${paginator.pageSize}" pageNumShown="10" currentPage="${paginator.pageIndex}"></div>
	</div>
</div>